{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="iskeys">
                                <option value="">是否购买私钥</option>
                                <option value="1" {if !empty(input('get.iskeys')) &&
                                    input('get.iskeys')==1}selected{/if}>是</option>
                                <option value="2" {if !empty(input('get.iskeys')) &&
                                    input('get.iskeys')==2}selected{/if}>否</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="ispartner">
                                <option value="">合伙人类型</option>
                                <option value="1" {if !empty(input('get.ispartner')) &&
                                    input('get.ispartner')==1}selected{/if}>否</option>
                                <option value="2" {if !empty(input('get.ispartner')) &&
                                    input('get.ispartner')==2}selected{/if}>是</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="isagent">
                                <option value="">社区长类型</option>
                                <option value="1" {if !empty(input('get.isagent')) &&
                                    input('get.isagent')==1}selected{/if}>否</option>
                                <option value="2" {if !empty(input('get.isagent')) &&
                                    input('get.isagent')==2}selected{/if}>是</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="status">
                                <option value="">冻结类型</option>
                                <option value="1" {if !empty(input('get.status')) &&
                                    input('get.status')==1}selected{/if}>否</option>
                                <option value="2" {if !empty(input('get.status')) &&
                                    input('get.status')==2}selected{/if}>是</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="mobile" placeholder="用户手机号|ID" value="{:input('get.mobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="pmobile" placeholder="推荐人手机号|ID" value="{:input('get.pmobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="code" placeholder="推荐码" value="{:input('get.code')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="data_edit('添加','user_add')"><i
                            class="layui-icon">&#xe654;</i>添加</button>&nbsp;
                    共有数据：<strong id="count">{$list->total()}</strong> 条 &nbsp;
                    老会员锁仓剩余:{$data.oldlockmoney}JTE,累计天数:{$data.oldlockdays}天
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form" lay-size="sm">
                        <thead>
                            <tr>
                                <th width="">ID</th>
                                <th width="">手机号</th>
                                <th width="">用户名</th>
                                <th width="">身份证号</th>
                                <th width="">股权数量</th>
                                <th width="">邀请码</th>
                                <th width="">是否购买私钥</th>
                                <th width="">推荐人信息</th>
                                <th width="">锁仓累计</th>
                                <th width="">是否合伙人</th>
                                <th width="">是否社区长</th>
                                <th width="">冻结状态</th>
                                <th width="">功能开关</th>
                                <th width="">团队开关</th>
                                <th width="">有效直推</th>
                                <th width="">伞下总人数</th>
                                <th width="">老系统锁仓剩余JTE</th>
                                <th width="">老系统锁仓剩余天数</th>
                                <th width="">注册时间</th>
                                <th width="">资产记录</th>
                                <th width="">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>{$v.id|default='0'}</td>
                                <td>{$v.mobile|default=''}</td>
                                <td>{$v.name|default=''}</td>
                                <td>{$v.cards|default=''}</td>
                                <td>{$v.equity|default='0'}</td>
                                <td>{$v.code|default=''}</td>
                                <td>{if !empty($v.activakeys)}
                                    <button onclick="orderstr('确定要切换私钥购买状态吗？','/user/userskeys','{$v.id}',1)"
                                        type="button" class="layui-btn layui-btn-warm">是</button>
                                    {else}
                                    <button onclick="orderstr('确定要切换私钥购买状态吗？','/user/userskeys','{$v.id}',1)"
                                        type="button" class="layui-btn layui-btn-normal">否</button>
                                    {/if}
                                </td>
                                <td>ID:{$v.pid|default='0'}<br />手机号:{$v.pmobile}</td>
                                <td>${$v.lockmoney|default='0'}&nbsp;
                                    <button type="button" onclick="orderlockstr('/user/lockmoney_edit','{$v.id}')"
                                        class="layui-btn layui-btn-xs">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button></td>
                                <td>{if $v.ispartner == 1}
                                    <button onclick="orderstr('确定要切换合伙人状态吗？','/user/userstart','{$v.id}',1)"
                                        type="button" class="layui-btn layui-btn-warm">否</button>
                                    {else}
                                    <button onclick="orderstr('确定要切换合伙人状态吗？','/user/userstart','{$v.id}',1)"
                                        type="button" class="layui-btn layui-btn-normal">是</button>
                                    {/if}
                                </td>
                                <td>{if $v.isagent == 1}
                                    <button onclick="orderstr('确定要切换社区长状态吗？','/user/userstart','{$v.id}',2)"
                                        type="button" class="layui-btn layui-btn-warm">否</button>
                                    {else}
                                    <button onclick="orderstr('确定要切换社区长状态吗？','/user/userstart','{$v.id}',2)"
                                        type="button" class="layui-btn layui-btn-normal">是</button>
                                    {/if}
                                </td>
                                <td>{if $v.status == 1}
                                    <button onclick="orderstr('确定要切换会员状态吗？','/user/userstart','{$v.id}',3)"
                                        type="button" class="layui-btn layui-btn-normal">正常</button>
                                    {else}
                                    <button onclick="orderstr('确定要切换会员状态吗？','/user/userstart','{$v.id}',3)"
                                        type="button" class="layui-btn layui-btn-danger">冻结</button>
                                    {/if}
                                </td>
                                <td>{if $v.switchclose == 1}
                                    <button onclick="orderstr('确定要切换功能状态吗？','/user/userstart','{$v.id}',4)"
                                        type="button" class="layui-btn layui-btn-normal">正常</button>
                                    {else}
                                    <button onclick="orderstr('确定要切换功能状态吗？','/user/userstart','{$v.id}',4)"
                                        type="button" class="layui-btn layui-btn-danger">关闭</button>
                                    {/if}
                                </td>
                                <td>{if $v.teamstatus == 1}
                                    <button onclick="orderstr('确定要切换团队状态吗？','/user/userstart','{$v.id}',6)"
                                        type="button" class="layui-btn layui-btn-normal">正常</button>
                                    {else}
                                    <button onclick="orderstr('确定要切换团队状态吗？','/user/userstart','{$v.id}',6)"
                                        type="button" class="layui-btn layui-btn-danger">封锁</button>
                                    {/if}
                                </td>
                                <td>{$v.effepeople|default='0'}人</td>
                                <td>{$v.teampople|default='0'}人</td>
                                <td>{$v.oldlockmoney|default='0'}JTE</td>
                                <td>{$v.oldlockdays|default='0'}人</td>
                                <td>{$v.created|default=''}</td>
                                <td><button onclick="usermoney('/user/money_log','{$v.id}')" type="button"
                                        class="layui-btn layui-btn-danger">查看</button></td>
                                <td class="td-manage">
                                    <a title="编辑" onclick="data_edit('编辑','/user/user_edit?id={$v.id}')"
                                        href="javascript:;" class="layui-btn">
                                        编辑
                                    </a>
                                </td>

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['upload', 'form'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , form = layui.form;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'users_top'
            , accept: 'file'
            , exts: 'xls|csv'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.status > 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                return layer.msg(res.msg);
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });
    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
    function orderstr(title, url, id, type) {
        layer.confirm(title, { title: '请谨慎操作' }, function (index) {
            $.post(url, { id: id, type: type }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
    function usermoney(url, id) {
        layer.open({
            type: 2,
            area: ['80%', '80%'],
            content: url + '?mobile=' + id,
        });
    }

    function orderlockstr(url, user_id) {
        layer.prompt({
            value: '0',
            title: '请写入需要修改的数量，大于0表示增加，小于0表示减少',
        }, function (value, index, elem) {
            $.post(url, { user_id: user_id, money: value }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
</script>
{include file="public/footer"}